/* Created on Sep 29, 2010 */
package org.tdwg.codeblitz.model;

import java.util.logging.Level;
import java.util.logging.Logger;

import javax.xml.bind.annotation.XmlRootElement;



/**
 * @author Ian Cottingham
 *
 */
@XmlRootElement(name="point")
public class Point {

	public static final String TABLE_ID = "265100";
	
	private final Logger LOG = Logger.getLogger(Point.class
			.getCanonicalName());
	
	private String guid; 
	private double lat;
	private double lon;
	private String date;
	private double elevation;
	
	public Point() { }
	
	/* this is kind of obfuscated with the array pass, should be refactored */
	public Point(String fusionTablesRow) {
		String[] columns = fusionTablesRow.split(",");

		this.guid = columns[0];
		String[] location = columns[1].replace("\"", "").split(" ");
		if ( location.length != 2 ) { 
			LOG.log(Level.WARNING, "The location string was not valid: "+columns[1]);
		} else { 
			this.lat = Double.parseDouble(location[0]);
			this.lon = Double.parseDouble(location[1]);
		}
		
		this.date = columns[2];
		this.elevation = Double.parseDouble(columns[3]);
	}
	
	public String getGuid() {
		return guid;
	}
	
	public void setGuid(String guid) {
		this.guid = guid;
	}
	
	public double getLat() {
		return lat;
	}
	
	public void setLat(double lat) {
		this.lat = lat;
	}
	
	public double getLon() {
		return lon;
	}
	
	public void setLon(double lon) {
		this.lon = lon;
	}
	
	public String getDate() {
		return date;
	}
	
	public void setDate(String date) {
		this.date = date;
	}
	
	public double getElevation() {
		return elevation;
	}
	
	public void setElevation(double elevation) {
		this.elevation = elevation;
	}
}
